package com.xy.repository;

import com.xy.entity.TestDemo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * Created by Thinkpad on 2018/1/4.
 */
public interface TestDemoRepository extends JpaRepository<TestDemo, String> {

    TestDemo findById(String id);

    List<TestDemo> findByIdLike(String id);

    TestDemo findByIdAndName(String id,String name);

    @Query(value = "select  t from TestDemo t where t.name = :name")
    TestDemo findTestDemo(@Param("name") String addressInfo);


    @Query(value = "select o.* from TestDemo o  where o.name=?1", nativeQuery = true)
    @Modifying
    public List<TestDemo> findByName(String name);
}
